<template>
    <van-cell-group class="bg-header">
        <van-cell>
            <template #icon>
                <van-button v-if="leftArrow" class="header-button-1" @click="onClickLeft">
                    <van-icon name="cross"></van-icon>
                </van-button>
            </template>
            <template #title>
                {{title}}
            </template>
            <template #right-icon>
                <van-icon name="wap-home-o"/>
            </template>
        </van-cell>
    </van-cell-group>
</template>

<script>

    export default {
        name: 'bpmNavBar',
        props: {
            title: {
                type: String,
                default: ""
            },
            leftArrow: {
                type: Boolean,
                default: true
            },
            toIndex: {
                type: Boolean,
                default: false
            },
        },
        data() {
            return {}
        },
        methods: {
            onClickLeft() {
                if (!this.leftArrow) {
                    return;
                }
                if (this.toIndex) {
                    this.$router.push("/index");
                } else {
                    this.$emit("close");
                }
            }
        }
    }
</script>
